package com.ycw.servlet.guoguo;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.ycw.dao.TenantDao;
import com.ycw.dao.impl.HouseRepairDaoImpl;

/**
 * Servlet implementation class HouseRepairQueryRoomnumServlet
 */
@WebServlet("/houseRepairQueryRoomnumServlet")
public class HouseRepairQueryRoomnumServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * 根据地区，小区，单元号下拉框 返回房间号列表
	 */
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String h_region = request.getParameter("h_region");
		String h_village = request.getParameter("h_village");
		String h_unit = request.getParameter("h_unit");
		TenantDao td = HouseRepairDaoImpl.getInstance();
		List<String> list = td.tenantRoomnum(h_region, h_village, h_unit);
		String resJSON = JSON.toJSONString(list);
		PrintWriter out = response.getWriter();
		out.write(resJSON);
		out.close();

	}

}
